import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class KeyDetector implements KeyListener {
	
	private GameController controller;
	
	public KeyDetector(GameController controller){
		this.controller = controller;
	}
	
	public String translate(int code){
		if (code == 37) return "Izquierda";
		else if (code == 38) return "Arriba";
		else if (code == 39) return "Derecha";
		else if (code == 40) return "Abajo";
		else return KeyEvent.getKeyText(code);
	}
	
	@Override
	public void keyTyped(KeyEvent e) {
	}

	@Override
	public void keyPressed(KeyEvent e) {
		System.out.println(this.translate(e.getKeyCode()));
		controller.moveRedCar(this.translate(e.getKeyCode()));
	}

	@Override
	public void keyReleased(KeyEvent e) {
	}
}